﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using VK.Casemeet.Merchants;
using VK.Comm;
using VK.Casemeet.TravelLogs;
using VK.Comm.TransactSql;
using System.Data;

namespace VK.Casemeet.Web.ShopFront
{
    public partial class TravelLogList : System.Web.UI.Page
    {
        public ShopEntity shop = new ShopEntity();

        protected void Page_Load(object sender, EventArgs e)
        {
            int shopID = Util.GetRouteDataInt("ShopID");
            if (shopID != 0)
            {
                shop = ShopBLL.GetShop(shopID);
                (this.Master as Site).shop = shop;
                ShopCard1.shop = shop;
            }

            if (!IsPostBack)
            {
                aspNetPager.RecordCount = TravelLogBLL.GetTravelLogCount(GetCondition());
            }
        }

        protected void LoadData()
        {
            rptTravelLog.DataSource = TravelLogBLL.GetTravelLogList(aspNetPager.StartRecordIndex, aspNetPager.EndRecordIndex, GetCondition(), null, SortMode.Desc);
            rptTravelLog.DataBind();
        }

        protected IList<Condition> GetCondition()
        {
            IList<Condition> conditionlst = new List<Condition>();
            conditionlst.Add(new Condition { TableName = "TravelLog", FieldName = "ObjectType", ConditionType = ConditionType.NumeralEqual, ConditionValue = 1, DbType = DbType.Int32 });
            conditionlst.Add(new Condition { TableName = "TravelLog", FieldName = "ObjectID", ConditionType = ConditionType.NumeralEqual, ConditionValue = shop.ShopID, DbType = DbType.Int32 });
            conditionlst.Add(new Condition { TableName = "TravelLog", FieldName = "IsEnable", ConditionType = ConditionType.BoolEqual, ConditionValue = true, DbType = DbType.Boolean });
            return conditionlst;
        }

        protected void aspNetPager_PageChanged(object sender, EventArgs e)
        {
            LoadData();
        }
    }
}